# Project: init
# Makefile created by Dev-C++ 5.11

CPP      = g++.exe
CC       = gcc.exe
LD		 = ld.exe
WINDRES  = windres.exe
AS		 = nasm.exe
ASFLAGS	 = -f coff
OBJ      = ./../build/init/startup32.o ./../build/init/globaldata.o ./../build/init/go32.o
LINKOBJ  = ./../build/init/startup32.o ./../build/init/globaldata.o ./../build/init/go32.o
EXTLIBS	 = ./../build/init/init.o ./../build/kernel/kernel.o ./../build/std/std.o ./../build/arch/i386-arch.o ./../build/dev/dev.o ./../build/fs/vfs.o
LIBS     = -L"C:/Program Files/Dev-Cpp/MinGW64/lib32" -L"C:/Program Files/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib32" -static-libgcc -m32
INCS     = -I./../include -I./../include/init
CXXINCS  = -I./../include -I./../include/init
BIN      = ../build/init/init.o
KRNLBIN	 = ../build/targets/kernel.o
MAPFILE	 = .\..\build\targets\map.txt
CXXFLAGS = $(CXXINCS) -m32 -O3
CFLAGS   = $(INCS) -m32 -O3
RM       = rm.exe -f

.PHONY: all all-before all-after clean clean-custom

all: all-before $(KRNLBIN) all-after

clean: clean-custom
	${RM} $(OBJ) $(BIN)

$(KRNLBIN): $(BIN)
	$(LD) -s -x -M -Ttext 0xC0110000 -e _go32 -o $(KRNLBIN) $(EXTLIBS) >$(MAPFILE)
	objcopy -R .note -R .comment -S -O binary $(KRNLBIN) $(KRNLBIN).bin

$(BIN): $(OBJ)
	$(LD) -r $(LINKOBJ) -o $(BIN)

./../build/init/startup32.o: startup32.c
	$(CC) -c startup32.c -o ./../build/init/startup32.o $(CFLAGS)

./../build/init/globaldata.o: globaldata.c
	$(CC) -c globaldata.c -o ./../build/init/globaldata.o $(CFLAGS)

./../build/init/go32.o : go32.asm
	$(AS) $(ASFLAGS) go32.asm -o ./../build/init/go32.o